package homework.ls;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class FtpClient {

	public static void main(String[] args) throws Exception {
		String[] command = null;
		Socket socket=new Socket("127.0.0.1",8001);
		OutputStream out=socket.getOutputStream();
		InputStream in=socket.getInputStream();
		BufferedReader reader=new BufferedReader(new InputStreamReader(in));
		Scanner scanner=new Scanner(System.in);
		command = scanner.nextLine().split("\\s+");
		while (!command[0].equals("LS")) {
			System.out.println("Error,please input again...");
			command = scanner.nextLine().split("\\s+");
		}
		out.write((command[1]+"\n").getBytes());   //传文件路径的参数
		
		reader = new BufferedReader(new InputStreamReader(in));
		String s=reader.readLine();
		while (!s.equals("finished")) {
			System.out.println(s);
			s=reader.readLine();
			
		}
		

		
		

		out.close();
		reader.close();
		socket.close();
		

	}

}
